namespace SelfManagement.Database.MySql.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class init : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Daily",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                        User_Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                        TaskName = c.String(maxLength: 50, storeType: "nvarchar"),
                        Date = c.DateTime(nullable: false, precision: 0),
                        Performance = c.String(maxLength: 2000, storeType: "nvarchar"),
                        Status = c.Int(nullable: false),
                        IsDelete = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        CreatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.User", t => t.User_Id, cascadeDelete: true)
                .Index(t => t.User_Id);
            
            CreateTable(
                "dbo.DailyTask",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                        TaskName = c.String(maxLength: 200, storeType: "nvarchar"),
                        EstimateTime = c.Int(nullable: false),
                        RealTime = c.Int(nullable: false),
                        Status = c.Int(nullable: false),
                        Order = c.Int(nullable: false),
                        IsDelete = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        CreatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        Daily_Id = c.String(maxLength: 128, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Daily", t => t.Daily_Id)
                .Index(t => t.Daily_Id);
            
            CreateTable(
                "dbo.User",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128, storeType: "nvarchar"),
                        UserName = c.String(maxLength: 50, storeType: "nvarchar"),
                        TrueName = c.String(maxLength: 50, storeType: "nvarchar"),
                        Password = c.String(maxLength: 50, storeType: "nvarchar"),
                        UserFace = c.String(maxLength: 500, storeType: "nvarchar"),
                        Email = c.String(maxLength: 50, storeType: "nvarchar"),
                        Phone = c.String(maxLength: 50, storeType: "nvarchar"),
                        Status = c.Int(nullable: false),
                        FailedPasswordAttemptCount = c.Int(nullable: false),
                        LastLockoutDate = c.DateTime(precision: 0),
                        LastLoginDate = c.DateTime(precision: 0),
                        IsDelete = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedTime = c.DateTime(nullable: false, precision: 0),
                        UpdatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                        CreatedBy = c.String(nullable: false, maxLength: 50, storeType: "nvarchar"),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Daily", "User_Id", "dbo.User");
            DropForeignKey("dbo.DailyTask", "Daily_Id", "dbo.Daily");
            DropIndex("dbo.DailyTask", new[] { "Daily_Id" });
            DropIndex("dbo.Daily", new[] { "User_Id" });
            DropTable("dbo.User");
            DropTable("dbo.DailyTask");
            DropTable("dbo.Daily");
        }
    }
}
